<.focus_box>
  <:title>
    {Phoenix.Flash.get(@flash, :login_title) || "Enter your account credentials"}
  </:title>
  <:subtitle>
    <%= if Phoenix.Flash.get(@flash, :login_instructions) do %>
      <p class="text-gray-500 mt-1 mb-2">
        {Phoenix.Flash.get(@flash, :login_instructions)}
      </p>
    <% end %>
  </:subtitle>
  <.form :let={f} for={@conn} action="/login">
    <div class="my-4 mt-8">
      <.input
        type="email"
        autocomplete="username"
        placeholder="user@example.com"
        field={f[:email]}
        label="Email"
      />
    </div>
    <div class="my-4">
      <.input
        type="password"
        autocomplete="current-password"
        id="current-password"
        field={f[:password]}
        label="Password"
      />
    </div>

    <%= if login_error = Phoenix.Flash.get(@flash, :login_error) do %>
      <div class="text-red-500 mt-4">{login_error}</div>
    <% end %>

    <.input type="hidden" field={f[:return_to]} />

    <.button class="w-full" type="submit">Log in</.button>
  </.form>

  <:footer>
    <.focus_list>
      <:item :if={
        Keyword.fetch!(Application.get_env(:plausible, :selfhost), :disable_registration) == false
      }>
        Don't have an account?
        <.styled_link href="/register">
          Register
        </.styled_link>
        instead.
      </:item>
      <:item :if={ee?()}>
        <%= on_ee do %>
          Have a Single Sign-on account?
          <.styled_link href={
            Routes.sso_path(@conn, :login_form,
              return_to: @conn.params["return_to"],
              prefer: "manual"
            )
          }>
            Sign in here
          </.styled_link>
          instead.
        <% end %>
      </:item>
      <:item>
        Forgot password?
        <.styled_link href="/password/request-reset">
          Click here
        </.styled_link>
        to reset it.
      </:item>
    </.focus_list>
  </:footer>
</.focus_box>
